{$CLEO .cm}
{$USE cleo+}

$onmission=2
0000:
model.Load(#SHAMAL)
model.Load(#HUNTLEY)
model.Load(#MP5LNG)
model.Load(#TEC9)
model.Load(#COLT45)
model.Load(#SAWNOFF)
model.Load(#NRG500)
model.Load(#AK47)
model.Load(#SHOTGSPA)
load_requested_models 
const
    mission_has_failed = 1000@ 
    dialog_completed = 1001@ 
    npc = 1002@
    motor_vehicle = 1003@ 
      delay_random_target  = 900@  
     delay_zombie_voice   = 901@   
     wave_weapon       = 902@  
     wave_health       = 903@  
     wave_skin         = 904@  
     wave_attack_rate    = 905@  
     wave_skill          = 906@  
     wave_Accuracy       = 907@  
     wave_no_erupted       = 908@  
     wave_headshot           = 909@  
     wave_noanims             = 910@  
     wave_fightingstyle       = 911@  
     wave_bulletproof       = 912@ 
     wave_fireproof             = 913@ 
     wave_explosionproof        = 914@ 
     wave_collisionproof        = 915@ 
     wave_meleeproof          = 916@ 
     wave_drown                 = 917@ 
     wave_bleed                = 918@ 
     wave_marker                  = 919@ 
     wave_dont_chase_target          = 920@ 
     wave_kill_player_instantly   = 921@ 
     wave_decision_maker       = 922@ 
     wave_money                 = 923@ 
     wave_no_interupted           = 924@ 
   wave_walkstyles = 925@v 

   Player_plane = 200@  
   Location = 201@  
   
   Drug_king = 202@  
                 {
       juggerunut_delay_despawn_time = 0
       juggerunut_active = 0 
       BRUTE_HEALTH = 3000
       BRUTE_Accuracy = 70
       BRUTE_attack_rate = 70
       BRUTE_skin = #WMYBOUN  }  
end 
    //Defaults
      wave_weapon           = 31
      wave_health           = 300
     // wave_skin             = #MAFFA
      wave_attack_rate      = 70
      wave_skill            = 1
      wave_Accuracy         = 50
      wave_no_interupted    = 0 
      wave_headshot         = 0 
      wave_noanims          = 0
      wave_fightingstyle    = 7
      wave_bulletproof      = 0 
      wave_fireproof        = 0 
      wave_explosionproof   = 0 
      wave_collisionproof   = 0 
      wave_meleeproof       = 0 
      wave_drown            = 0                                                     
      wave_bleed            = 0 
      wave_marker            = 2 
      wave_dont_chase_target = 1
      wave_money = 0 
     wave_walkstyles = "player" 
mission_has_failed = 0 
dialog_completed = 0 


//start 

//show_styled_text "~w~Start dummy!" 3000 2 

fade 0 1000
wait 1000
fade 1 1000
actor_remove_from_car_and_put_at player1  -1567.4912 -7465.8057 7.8366
actor.Angle(player1)=  261.5806
gosub @spawn_player2  
0395: clear_area 1 at  377.0152 -4413.3467 12.2808  radius 999999999.0

//Base

// 0085: 13@ = 12@ // (int)
   :CheckFirst
   wait 0
    if and 
    model.Available(#SHAMAL)
    model.Available(#HUNTLEY)
    model.Available(#NRG500)
    
   jf @CheckFirst
   Player_plane = car.Create( #SHAMAL , -1571.3862, -7471.8872, 7.8366)
   car.Angle( player_plane ) = 271.7254
   car.Health(Player_plane ) = 50000
   09C4: set_car player_plane gas_tank_explosion_enabled 0
 
   40@ = car.Create( #HUNTLEY , 345.7057, -3296.1538, 10.99)
   car.Angle( 40@ ) = 96.2293
   car.Health(40@ ) = 50000
   09C4: set_car 40@ gas_tank_explosion_enabled 0
   
   marker.CreateAboveCar( 50@ , Player_plane )
   07E0: set_marker 50@ type_to 1
   018B: set_marker 50@ radar_mode 2
   marker.CreateAboveCar( 51@ , 40@ )
   07E0: set_marker 51@ type_to 1
   018B: set_marker 51@ radar_mode 2  
   42@ = car.Create( #NRG500 ,  -27.0396, -3587.8853, 0.7767)
   car.Angle( 42@ ) = 91.8482
   car.Health(42@ ) = 50000
   09C4: set_car 42@ gas_tank_explosion_enabled 0
   
   
   model.destroy(#SHAMAL)
   model.destroy(#HUNTLEY)
   model.destroy(#NRG500)
  
  show_styled_text "~w~Plane of Landing for Drugs" 3000 2
  wait 400
 
   018A: Location = create_checkpoint_at  348.3367 -3287.0906 12.9149
   show_text_highpriority "Fly to the ~y~Northside~w~ of the Rail Den City" 4000 
   dialog_completed = 0 
   mission_has_failed=0
while true
wait 0
    gosub @mission_status   
    // cleo_call @TestDail 0
    if mission_has_failed==1
    then
        Goto @CloseDowntheMission 
    end
    if  00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere  348.3367 -3287.0906 12.9149 radius 120.0 120.0 300.0

    then
           marker.Disable(Location)
              018A: Location = create_checkpoint_at  -407.9995 -3165.1389 5.3097

            show_text_highpriority "Head to the ~g~subway station~W~ to get to the ~y~sewers~w~." 4000 

            while true 
            wait 0
                    gosub @mission_status   
                    if mission_has_failed==1
                    then
                        Goto @CloseDowntheMission 
                    end   
                    if  00FE:   actor $PLAYER_ACTOR sphere 1 in_sphere  -407.9995 -3165.1389 5.3097   radius 10.0 10.0 3.0
                    then 
                         model.Load(#MAFFA)
                         model.Load(#MAFFb)
                         model.Load(#MAFBOSS) 
                         
                         while true 
                         wait 0 
                             if and 
                             model.Available(#MAFFA)
                             model.Available(#MAFFb)
                             model.Available(#MAFBOSS)
                            then
                                break 
                            end 
                         end 
                         marker.Disable(Location)
                         show_text_highpriority "Look for the ~r~Drug Dealer~w~. He's hiding somewhere." 4000 
                         80@=actor.Create(14,#MAFFA,220.384, -3478.3833, 4.4562)
                         actor.Angle(80@)=34.2865
                         81@=actor.Create(14,#MAFFA,236.4217, -3491.0093, 4.44)
                         actor.Angle(81@)=118.629
                         82@=actor.Create(14,#MAFFb,232.2606, -3480.363, 5.3979)
                         actor.Angle(82@)=61.2716
                         83@=actor.Create(14,#MAFFb,246.8394, -3519.4556, 6.1443)
                         actor.Angle(83@)=35.5893
                         84@=actor.Create(14,#MAFFA,201.9795, -3530.9133, 4.44)
                         actor.Angle(84@)=308.5853
                         85@=actor.Create(14,#MAFFb,194.1901, -3569.8914, 4.44)
                         actor.Angle(85@)=36.352
                         86@=actor.Create(14,#MAFFA,133.0719, -3593.8315, 4.44)
                         actor.Angle(86@)=255.7316
                         87@=actor.Create(14,#MAFFb,83.6876, -3575.9971, 1.6297)
                         actor.Angle(87@)=225.9736
                         88@=actor.Create(14,#MAFFA,79.4812, -3608.2729, 1.6297)
                         actor.Angle(88@)=300.0431
                         89@=actor.Create(14,#MAFFb,38.5498, -3690.5613, 1.6297)
                         actor.Angle(89@)=331.7366
                         90@=actor.Create(14,#MAFFA,39.0981, -3692.2747, 1.6297 )
                         actor.Angle(90@)=341.0864 
                         91@=actor.Create(14,#MAFFA,44.7209, -3689.7141, 1.6297 )
                         actor.Angle(91@)=269.2687 
                         92@=actor.Create(14,#MAFFb,46.9291, -3663.1218, 1.623 )
                         actor.Angle(92@)=216.713 
                         93@=actor.Create(14,#MAFFb, 55.0815, -3671.0688, 1.623)
                         actor.Angle(93@)= 93.0098
                         94@=actor.Create(14,#MAFFA,64.2419, -3684.0178, 1.623 )
                         actor.Angle(94@)=20.0197 
                         95@=actor.Create(14,#MAFFA,76.1683, -3658.8992, 1.6297 )
                         actor.Angle(95@)= 253.0035
                         96@=actor.Create(14,#MAFFb,91.2612, -3631.7471, 1.6297 )
                         actor.Angle(96@)= 335.7269
                         97@=actor.Create(14,#MAFFb,80.7295, -3608.4175, 1.6297 )
                         actor.Angle(97@)=318.5867 


                         98@=actor.Create(14,#MAFFA, -436.3917, -4144.3403, 4.9197)
                         actor.Angle(98@)= 81.4905
                         99@=actor.Create(14,#MAFFb,-327.6329, -3844.7109, 4.9197 )
                         actor.Angle(99@)=74.7573 
                         100@=actor.Create(14,#MAFFA,-351.6999, -3889.314, 4.9197 )
                         actor.Angle(100@)= 58.9198
                         0085: npc = 98@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 99@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 100@ // (int)
                         gosub @NPC_STATS
     
                         actor.GiveWeaponAndAmmo(98@,ak47,9999999 )
                         actor.GiveWeaponAndAmmo(99@,ak47,9999999 )
                         actor.GiveWeaponAndAmmo(100@,ak47,9999999 )
                         04EB: AS_actor 85@ crouch 1
                         0085: npc = 80@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 81@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 82@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 83@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 84@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 85@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 86@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 87@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 88@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 89@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 90@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 91@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 92@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 93@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 94@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 95@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 96@ // (int)
                         gosub @NPC_STATS
                         0085: npc = 97@ // (int)
                         gosub @NPC_STATS 
                         actor.GiveWeaponAndAmmo(80@,tec9,99999) 
                         actor.GiveWeaponAndAmmo(81@,mp5,99999) 
                         actor.GiveWeaponAndAmmo(82@,mp5,99999) 
                         actor.GiveWeaponAndAmmo(83@,tec9,99999) 
                         actor.GiveWeaponAndAmmo(84@,sawnoff,99999) 
                         actor.GiveWeaponAndAmmo(85@,tec9,99999) 
                         actor.GiveWeaponAndAmmo(86@,mp5,99999) 
                         actor.GiveWeaponAndAmmo(87@,sawnoff,99999) 
                         actor.GiveWeaponAndAmmo(88@,tec9,99999) 
                         actor.GiveWeaponAndAmmo(89@,mp5,99999) 
                         actor.GiveWeaponAndAmmo(90@,mp5,99999) 
                         actor.GiveWeaponAndAmmo(91@,tec9,99999) 
                         actor.GiveWeaponAndAmmo(92@,sawnoff,99999) 
                         actor.GiveWeaponAndAmmo(93@,mp5,99999) 
                         actor.GiveWeaponAndAmmo(94@,sawnoff,99999) 
                         actor.GiveWeaponAndAmmo(95@,tec9,99999) 
                         actor.GiveWeaponAndAmmo(96@,sawnoff,99999) 
                         actor.GiveWeaponAndAmmo(97@,mp5,99999)  
                         
                         
                         Drug_king = actor.Create(14,#MAFBOSS, 39.4138, -3674.5747, 1.6297)
                         actor.Angle(Drug_king) = 263.816 
                          actor.WeaponAccuracy(Drug_king)=90
                          0446: set_actor Drug_king dismemberment_possible 0 
                          actor.Health( Drug_king ) =  2500
                          0446: set_actor Drug_king dismemberment_possible 0
                          07DD: set_actor Drug_king attack_rate 80 // previously known as temper_to
                          04EB: AS_actor Drug_king crouch 1
                          0638: AS_actor Drug_king stay_put 1

                          07FE: set_actor Drug_king fighting_style_to 7 moves 6
                          0946: set_actor Drug_king actions_uninterupted_by_weapon_fire wave_no_interupted
                          actor.GiveWeaponAndAmmo( Drug_king, CombatShotgun ,9999999)
                          actor.WeaponAccuracy(Drug_king)= wave_Accuracy
                          081A: set_actor Drug_king weapon_skill_to 1
                          04D8: set_actor Drug_king drowns_in_water 1
                           09B5: set_actor Drug_king signal_after_kill 0  
                          0816: set_actor Drug_king dont_chase_victim 1
                         05E2: AS_actor Drug_king kill_actor player1
                         077A: set_actor Drug_king acquaintance 4 to_actors_pedtype 0 // see ped.dat
                         077A: set_actor Drug_king acquaintance 4 to_actors_pedtype 1 // see ped.dat
                         077A: set_actor Drug_king acquaintance 4 to_actors_pedtype 8 // see ped.dat
                         model.Destroy( #MAFFA )
                         model.Destroy( #MAFFb )
                         model.Destroy( #MAFBOSS )
                        model.Destroy(#TEC9)
                        model.Destroy(#COLT45)
                        model.Destroy(#SAWNOFF)
                        model.Destroy(#SHOTGSPA)                         
                        model.Destroy(#AK47)                         
                         91@ = marker.CreateAboveActor( Drug_king )
                         018B: set_marker 91@ radar_mode 2


                         while true
                         wait 0
                                gosub @mission_status   
                                if mission_has_failed==1
                                then
                                    Goto @CloseDowntheMission 
                                end                           
                                if actor.Dead( Drug_king ) 
                                then
                                         marker.Disable( 91@ )
                                         model.Load(1575) 
                                         repeat
                                         wait 0 
                                         until model.Available( 1575 )
                                         310@ =pickup.Create( 1575 ,3, 51.641, -3661.5227, 1.6297 ) 
                                         311@= pickup.Create( 1575 ,3,36.832, -3671.627, 1.6297 ) 
                                         312@= pickup.Create( 1575 ,3,36.9886, -3681.9678, 1.6297) 
                                         313@ =pickup.Create( 1575 ,3,43.3735, -3697.2471, 1.6297 ) 
                                         314@= pickup.Create( 1575 ,3, 47.7008, -3697.2744, 1.6297) 
                                         315@= pickup.Create( 1575 ,3,37.1165, -3687.6802, 1.6297 ) 
                                         316@= pickup.Create( 1575 ,3, 37.9565, -3670.2974, 1.6297) 
                                         
                                         show_text_highpriority "Collect all the ~g~drug packages~w~." 4000 
                                        { 
                                        //Scrap this...
                                         
                                         300@ = object.Init( 1575 ,  )
                                         301@ = object.Init( 1575 ,  )
                                         302@ = object.Init( 1575 ,  )
                                         303@ = object.Init( 1575 ,  )
                                         304@ = object.Init( 1575 ,  )
                                         305@ = object.Init( 1575 ,  )
                                         306@ = object.Init( 1575 ,  )
                                         307@ = object.Init( 1575 ,  )
                                         }
                                         03DC: 320@ = create_marker_above_pickup 310@
                                         03DC: 321@ = create_marker_above_pickup 311@
                                         03DC: 322@ = create_marker_above_pickup 312@
                                         03DC: 323@ = create_marker_above_pickup 313@
                                         03DC: 324@ = create_marker_above_pickup 314@
                                         03DC: 325@ = create_marker_above_pickup 315@
                                         03DC: 326@ = create_marker_above_pickup 316@   
                                         32@ = 0                               
                                         while true
                                         wait 0
                                            gosub @mission_status   
                                            if mission_has_failed==1
                                            then
                                                Goto @CloseDowntheMission 
                                            end     
                                            if and
                                              89D1: not  pickup 311@ created
                                              89D1: not  pickup 312@ created
                                              89D1: not  pickup 313@ created
                                              89D1: not  pickup 314@ created
                                              89D1: not  pickup 315@ created
                                              89D1: not  pickup 316@ created 
                                            
                                            then
                                               jump @ALT
                                            end  
                                            if 32@ > 20000
                                            then
                                               jump @ALT
                                            end
                                            if and
                                                pickup.Picked_up(310@ )
                                                pickup.Picked_up(311@ )
                                                pickup.Picked_up(312@ )
                                                pickup.Picked_up(313@ )
                                                pickup.Picked_up(314@ )
                                                pickup.Picked_up(315@ )
                                                pickup.Picked_up(316@ )
                                            
                                            then
                                            :ALT
                                                 if 09D1:   pickup 310@ created
                                                 then
                                                      pickup.Destroy(310@)
                                                      
                                                 end 
                                                 if 09D1:   pickup 311@ created
                                                 then
                                                      pickup.Destroy(311@)
                                                 end 
                                                 if 09D1:   pickup 312@ created
                                                 then
                                                      pickup.Destroy(312@)
                                                 end 
                                                 if 09D1:   pickup 313@ created
                                                 then
                                                      pickup.Destroy(313@)
                                                 end 
                                                 if 09D1:   pickup 314@ created
                                                 then
                                                      pickup.Destroy(314@)
                                                 end 
                                                 if 09D1:   pickup 315@ created
                                                 then
                                                      pickup.Destroy(315@)
                                                 end 
                                                 if 09D1:   pickup 316@ created
                                                 then
                                                      pickup.Destroy(316@)
                                                 end                                             
                                                 if 09D1:   pickup 310@ created
                                                 then
                                                      pickup.Destroy(310@)
                                                      
                                                 end 
                                           
                                                 show_text_highpriority "Return to ~y~Wasteland Airport~w~." 4000 
                                                 018A: Location = create_checkpoint_at -1568.8867 -7470.2197 7.8366
                                                 while true 
                                                 wait 0     
                                                        gosub @mission_status   
                                                        if mission_has_failed==1
                                                        then
                                                            Goto @CloseDowntheMission 
                                                        end                                                     
                                                        if    00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere  -1568.8867 -7470.2197 7.8366 radius 20.0 20.0 5.0
                                                        then
                                                            marker.Disable(  Location )
                                                            Jump @end_the_mission 
                                                            break
                                                        end   
                                                 end 
                                                                       
                                        end
                                end 
                         end 
                    end     
            end     
    end 

   
end 
end
 
:end_the_mission 
show_styled_text "~y~Mission success!" 3000 5 
jump @CloseDowntheMission 

//Subs

:mission_status 
{
if is_car_defined  Player_plane
then
    if or 
    02BF:   car Player_plane sunk 
    car.Wrecked(Player_plane)
    then
       show_styled_text "~r~Plane is goner now!" 3000 5 
       mission_has_failed = 1  
    end
end         }
    if wasted_or_busted
    then
     show_styled_text "~r~You failed!" 3000 5 
       mission_has_failed = 1 
    end 
    if cheat "exit"
    then
     show_styled_text "~w~Aborted!" 3000 5 
       mission_has_failed = 1 
    end
return


//Speak

:TestDail
if dialog_completed==0
then
show_text_highpriority "Yo, what's up homie?" 3000
wait 3000
show_text_highpriority "I wanna tell you something." 3000
wait 3000
show_text_highpriority "Go down there and pickup drugs, okay?" 3000
wait 3000
show_text_highpriority "Enjoy the mission." 3000
wait 3000
dialog_completed=1 
end 
cleo_return 0
 
//Player 2 spawn 

:spawn_player2 
if coop
return_if_false
04C4: store_coords_to 40@ 41@ 42@ from_actor player1 with_offset 0.0 -1.0 -1.0
43@=actor.Angle(player1)
actor.Angle(player2)=43@
actor_remove_from_car_and_put_at   player2   40@ 41@ 42@

return  

//cleanup 
:CloseDowntheMission 
$onmission=0
marker.Disable(Location)
 if 09D1:   pickup 310@ created
 then
      pickup.Destroy(310@)
 end 
 if 09D1:   pickup 311@ created
 then
      pickup.Destroy(311@)
 end 
 if 09D1:   pickup 312@ created
 then
      pickup.Destroy(312@)
 end 
 if 09D1:   pickup 313@ created
 then
      pickup.Destroy(313@)
 end 
 if 09D1:   pickup 314@ created
 then
      pickup.Destroy(314@)
 end 
 if 09D1:   pickup 315@ created
 then
      pickup.Destroy(315@)
 end 
 if 09D1:   pickup 316@ created
 then
      pickup.Destroy(316@)
 end 
fade 0 1000
wait 1000
fade 1 1000
mission_cleanup
end_Thread 



:CAR_STATS
if car_defined motor_vehicle
return_if_false
      car.Health(motor_vehicle)=30000
      09C4: set_car motor_vehicle gas_tank_explosion_enabled 0

return 

:NPC_STATS
if actor_defined  npc
return_if_false
      actor.WeaponAccuracy(npc)=60
      0446: set_actor npc dismemberment_possible 0 
      actor.Health( npc ) =  wave_health
      0446: set_actor npc dismemberment_possible 0
      07DD: set_actor npc attack_rate 76 // previously known as temper_to

      07FE: set_actor npc fighting_style_to 5 moves 6
     // 0946: set_actor npc actions_uninterupted_by_weapon_fire wave_no_interupted
    //  actor.GiveWeaponAndAmmo( npc, wave_weapon ,9999999)
      actor.WeaponAccuracy(npc)= wave_Accuracy
      081A: set_actor npc weapon_skill_to 1
      04D8: set_actor npc drowns_in_water 1
       09B5: set_actor npc signal_after_kill 0  
      0816: set_actor npc dont_chase_victim 1
    
     077A: set_actor npc acquaintance 4 to_actors_pedtype 0 // see ped.dat
     077A: set_actor npc acquaintance 4 to_actors_pedtype 1 // see ped.dat
     077A: set_actor npc acquaintance 4 to_actors_pedtype 8 // see ped.dat
    05E2: AS_actor npc kill_actor player1
return
